package ch03.cat;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class IntermediaryIntemediaryCat implements InvocationHandler {
    private Object cat;

    public void setCat(Object cat) {
        this.cat = cat;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        defore();
        Object msg=method.invoke(cat,args);
        after();
        return msg;
    }
    public void defore(){
        for (int i=0;i<3;i++){
            System.out.println("第"+(i+1)+"次看车");
        }
    }
    public void after(){
        System.out.println("付款成功");

    }
}
